
package org.testis.testdriver;

import org.testis.testdriver.AtofEnumaration.DebuggingMode;



/**
 * This class is the factory class of the Driver Factory Design Pattern
 * @author barisergun
 */


public class DriverFactory {
    
    public ExecutionDriver getInstance(DebuggingMode mode)

    {
        ExecutionDriver driver = null;
        try {

            Class<?> cls = Class.forName("org.testis.testdriver." +mode.name() + "Driver");
            driver = (ExecutionDriver) cls.newInstance();
        } catch (InstantiationException ex) {
            
        } catch (IllegalAccessException ex) {
            
        } catch (ClassNotFoundException ex) {
            
            
        }
        finally
        {
            if(driver == null)
            {
                driver = new NormalRunDriver();
            }
        }

        /*
        switch(mode)
        {
            case NormalRun:
                driver = new NormalRunDriver();
                break;
            case Debugging:
                driver = new DebuggingDriver();
                break;   
            case FailedDebugging:
                driver = new FailedDebuggingDriver();
                break;                
            default:                    
                driver = new NormalRunDriver();
                break;
        }
         * */

        return driver;
        
            
    }

}
